<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang bbs.topic.view.header}</h3>
				</div>
				<div class="widget-content">
					<form class="form-search" id="frm_search" name="frmSearch" action="{$ADMIN_SCRIPT}/bbs/topic" method="post">
						<div class="action-wrapper">
							<div class="pull-left">
								<a href="javascript:void(null);" id="btn_pass_list"  class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.pass}</a>
								<a href="javascript:void(null);" id="btn_fail_list"  class="btn btn-small" {$dispatches[operations][audit]}>{lang admin.operation.fail}</a>
								<a href="javascript:void(null);" id="btn_move_list"  class="btn btn-small" >{lang admin.operation.move}</a>
								<a href="javascript:void(null);" id="btn_delete_list"  class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
								<a href="{$ADMIN_SCRIPT}/bbs/topic/_pub" id="btn_submit"  class="btn btn-small" {$dispatches[operations][add]}>{lang bbs.topic.view.operation.add}</a>
							</div>
							<div class="pull-right" {$dispatches[operations][search]}>
								<div class="input-append" >
									<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small search-query" size="18"  maxlength="20"/>
									<button type="submit" class="btn">{lang admin.search.submit}</button>
								</div>
								<button type="button" state="0" class="btn" id="btn_extend_search">{lang admin.search.submit.extend}<i class="micon-arrow-down"></i></button>
							</div>
						</div>
					</form>
					
					<div id="div_extend_search" style="display:none;">
						<hr/>
						<form id="frm_extend_search" name="frmExtendSearch" action="{$ADMIN_SCRIPT}/bbs/topic" method="post">
						<input type="hidden" name="hdnSearchShow" value="1" />
						<table>
						<tr>
							<td width="46">{lang admin.search.keyword}</td>
							<td>
								<label class="checkbox inline">
									<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small" maxlength="20"/>
								</label>
								<label class="checkbox inline">
						    	<select name="sltType">
						            <option value="0" {if $_var['gp_sltType'] == 0}selected="selected"{/if}>{lang bbs.topic.view.search.keyword.select.0}</option>
						            <option value="1" {if $_var['gp_sltType'] == 1}selected="selected"{/if}>{lang bbs.topic.view.search.keyword.select.1}</option>
						            <option value="2" {if $_var['gp_sltType'] == 2}selected="selected"{/if}>{lang bbs.topic.view.search.keyword.select.2}</option>
						            <option value="3" {if $_var['gp_sltType'] == 3}selected="selected"{/if}>{lang bbs.topic.view.search.keyword.select.3}</option>
						            <option value="4" {if $_var['gp_sltType'] == 4}selected="selected"{/if}>{lang bbs.topic.view.search.keyword.select.4}</option>
					            </select>
						        </label>
						        <label class="checkbox inline">
					        	<select name="sltSForumId">
						        	<option value="0">{lang bbs.topic.view.search.forum.select}</option>
						        	<!--{loop $forum_list $key $forum}-->
						        	<option value="{$forum[FORUMID]}" {if $forum[FORUMID] == $_var[gp_sltSForumId]}selected="selected"{/if}>{$forum[NAME]}</option>
						        	<!--{/loop}-->
					            </select>
						        </label>
						        <label class="checkbox inline">
						        <select name="sltIsAudit">
						            <option value="0">{lang bbs.topic.view.search.audit.select.0}</option>
						            <option value="1" {if $_var['gp_sltIsAudit'] == 1}selected="selected"{/if}>{lang bbs.topic.view.search.audit.select.1}</option>
						            <option value="2" {if $_var['gp_sltIsAudit'] == 2}selected="selected"{/if}>{lang bbs.topic.view.search.audit.select.2}</option>
						        </select>
						        </label>
						        <label class="checkbox inline">
						        <select name="sltIsTop">
						            <option value="0">{lang bbs.topic.view.search.top.select.0}</option>
						            <option value="1" {if $_var['gp_sltIsTop'] == 1}selected="selected"{/if}>{lang bbs.topic.view.search.top.select.1}</option>
						            <option value="2" {if $_var['gp_sltIsTop'] == 2}selected="selected"{/if}>{lang bbs.topic.view.search.top.select.2}</option>
					            </select>
						        </label>
							</td>
						</tr>
						<tr>
							<td>{lang admin.search.time}</td>
							<td>
								<input type="text" name="txtBeginDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtBeginDate]}" />
					            {lang admin.search.to}
					            <input type="text" name="txtEndDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtEndDate]}" />
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<button type="submit" class="btn btn-primary">{lang admin.search.submit.extend.submit}</button>
							</td>
						</tr>
						</table>
				    	</form>
					</div>
					
					<hr/>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/bbs/topic&do=delete_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" method="post">
					<input type="hidden" name="hdnMoveNoteID" value="0" />
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="30"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th>{lang bbs.topic.view.th.title}</th>
					            <th>{lang bbs.topic.view.th.forum}</th>
					            <th width="100">{lang bbs.topic.view.th.audit&reply}</th>
					            <th width="100">{lang bbs.topic.view.th.hit&attend}</th>
					            <th width="85">{lang bbs.topic.view.th.username}</th>
					            <th width="120">{lang bbs.topic.view.th.edittime}</th>
					            <th width="90">{lang bbs.topic.view.th.operate}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $topics $_loop $topic}-->
							<tr class="item-row">
								<td>
				                	<input type="checkbox" class="fancy" name="cbxItem[]" title="{$topic[TITLE]}" value="{$topic[FORUM_TOPICID]}"/>
				            	</td>
				            	<td>
					            	<a href="{$ADMIN_SCRIPT}/bbs/topic/_view&id={$topic[FORUM_TOPICID]}&ppage={$_var[page]}&ppsize={$_var[psize]}{$search[querystring]}" class="{echo $topic['ISAUDIT'] ? 'text-success' : 'text-error';}">{$topic[TITLE]}</a>
						            <!--{if $topic[ISTOP]}-->[{lang bbs.topic.view.td.istop}]<!--{/if}-->
						            <!--{if $topic[CLOSED]}-->[{lang bbs.topic.view.td.closed}]<!--{/if}-->
					            </td>
					            <td>{$topic[FORUMNAME]}</td>
					            <td>
					            	<!--{if $topic['ISAUDIT']}-->{lang bbs.topic.view.td.isaudit.pass}<!--{else}-->{lang bbs.topic.view.td.isaudit.fail}<!--{/if}--> / 
					            	{$topic[POSTCOUNT]}{lang bbs.topic.view.td.record}
					            </td>
					            <td>{$topic[HITS]}/{$topic[ATTENT]}</td>
					            <td class="f12">{$topic[USERNAME]}</td>
					            <td class="f12">{$topic[EDITTIME]}</td>
				            	<td>
				                	<a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/bbs/topic/_update&id={$topic[FORUM_TOPICID]}&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					                <a class="btn btn-mini btn-delete" title="{$topic[TITLE]}" data="{$topic[FORUM_TOPICID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
					            </td>
							</tr>
							<!--{/loop}-->
							<!--{if $count == 0}-->
					        <tr>
					            <td colspan="8">
					                * {lang admin.operation.empty}
					            </td>
					        </tr>
					        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
function search_toggle(){
	var state = $('#btn_extend_search').attr('state');
	if(state == '0'){
		$('#btn_extend_search').html('{lang admin.search.submit.extend.hide}<i class="micon-arrow-up"></i>').attr('state', '1');
	}else{
		$('#btn_extend_search').html('{lang admin.search.submit.extend}<i class="micon-arrow-down"></i>').attr('state', '0');
	}
	
	$('.pull-right .input-append').toggle();
	$('#div_extend_search').toggle();
	
}

$(function(){
	$('.fancy').uniform();
	$('.input-date').datepicker({format:'yyyy-mm-dd'});
	
	$('#btn_pass_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.pass}', message:'<p>{lang bbs.topic.view.operation.pass.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/bbs/topic&do=pass_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang bbs.topic.view.operation.empty}'});
	});
	
	$('#btn_fail_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.fail}', message:'<p>{lang bbs.topic.view.operation.fail.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/bbs/topic&do=fail_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang bbs.topic.view.operation.empty}'});
	});
	
	$('#btn_move_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			$.dialog({height:200, submit:'{lang admin.operation.move}', title:'{lang bbs.topic.view.operation.move.title}', href:'{$ADMIN_SCRIPT}/bbs/topic/_move', callback: function(){
            	$('#modal_dialog .btn-primary').click(function(){
            		var forumid = $('#slt_move_forum_id').val();
            		if(!forumid || forumid == '0'){
			        	$.dialog({message:'{lang bbs.topic.view.operation.move.empty}'});
			        	return false;
			        }
			        
            		$('#frm_grid').attr('action', "{$ADMIN_SCRIPT}/bbs/topic&do=move_list&hdnMoveForumID="+ forumid +"&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}");
			        $('#frm_grid').submit();
            	});
            }});
			
        }else $.dialog({message:'{lang bbs.topic.view.operation.empty}'});
	});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang bbs.topic.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/bbs/topic&do=delete_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang bbs.topic.view.operation.empty}'});
	});
	
	$('#btn_extend_search').click(function(){
		search_toggle();
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var topicid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('title') + '； </p>';
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang bbs.topic.view.operation.delete.one}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/bbs/topic&do=delete&id=' + topicid + '&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
				$('#frm_grid').submit();
			});
		}});
	});
	
	{if $_var[gp_hdnSearchShow]}
	search_toggle();
	{/if}
	
});
</script>
<!--{template /module/admin/view/foot}-->